
document.addEventListener('DOMContentLoaded', function () {
    var _years = document.querySelector('.year');
    var _months = document.querySelector('.month');
    var _days = document.querySelector('.day');
    var _week = document.querySelector('.currentDay-week');
    var _hours = document.querySelector('.hour');
    var _minutes = document.querySelector('.minute');
    var _seconds = document.querySelector('.second');
	var _seconds1 = document.querySelector('.second1');
    function setText(){
        var date = new Date();
        var years = date.getFullYear(),
            months =date.getMonth() + 1,
            days = date.getDate();
            weeks = date.getDay();
        var hours = date.getHours(),
            minutes = date.getMinutes();
           seconds = date.getSeconds();
        _years.innerHTML = years;
        if(months < 10){
            _months.innerHTML =String(0) + String(months);
        }else{
            _months.innerHTML =  months;
        };
        if(days < 10){
            _days.innerHTML =String(0) + String(days);
        }else{
            _days.innerHTML = days;
        };
        if(weeks == 1){
            _week.innerHTML = 'Mon';
        }else if(weeks == 2){
            _week.innerHTML = 'Tue';
        }else if(weeks == 3){
            _week.innerHTML = 'Wed';
        }else if(weeks == 4){
            _week.innerHTML = 'Thu';
        }else if(weeks == 5){
            _week.innerHTML = 'Fri';
        }else if(weeks == 6){
            _week.innerHTML = 'Sat';
        }else{
            _week.innerHTML = 'Sun';
        };
        
        if(hours < 10){
            _hours.innerHTML =String(0) + String(hours);
        }else{
            _hours.innerHTML = hours;
        };
		
		
		if(hours < 6){
		    _hours.innerHTML =String(0) + String(hours);
		}else{
		    _hours.innerHTML = hours;
		};
		
        
        if(minutes < 10){
            _minutes.innerHTML =String(0) + String(minutes);
        }else{
            _minutes.innerHTML = minutes;
        };
		if(hours <12){_seconds1.innerHTML = 'AM'}
		else {_seconds1.innerHTML = 'PM'} 
		
        if(seconds < 10){
            _seconds.innerHTML =String(0) + String(seconds);
        }else{
            _seconds.innerHTML = seconds;
        };
    }
    setText();
    setInterval(function () {
        setText();
    }, 1000);
});